package com.lemei.cn.utils;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lemei.cn.lemeiapp.R;

/**
 * Created by 赵航 on 2017/6/4.
 */

public class FragmentUtils extends Fragment{
    private String mCode;
    private View rootView;
    private TextView mTextView;

    //将数据跟fragment进行绑定实现一对一的；

    public static FragmentUtils getInstance(String code){

        FragmentUtils fragmentUtils = new FragmentUtils();

        Bundle bundle = new Bundle();
        bundle.putString("code",code);

        fragmentUtils.setArguments(bundle);

        return fragmentUtils;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle bundle = getArguments();
        mCode = bundle.getString("code");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.besic_layout, container, false);


        return rootView;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mTextView = (TextView) view.findViewById(R.id.text_fragment);
        mTextView.setText(mCode);
    }
}
